#include <stdio.h>
#include <string.h>
#include <math.h>

double s[50000];
double up[50000];
double tot;
char str[100];
char out[160000];
int  maxnum;

void init()
{
	int i, j, shu, len;

	memset(s, 0, sizeof(s));
	memset(up, 0, sizeof(up));
	strcpy(out,"");
	shu = 1;
	tot = 0;
	while (tot <= 2147483647 && tot>=0)
	{
		sprintf( str, "%d", shu);
		strcat(out, str);
		len = strlen( str );
		s[shu] = s[shu-1] + len;
		tot += s[shu];
		up[shu] = tot;
//		printf("No.%d, len=%.0lf, tot=%.0lf\n", shu, s[shu], tot);
//		if (shu<100) printf("%.0lf\n", up[shu]);
		shu ++;
	}
/*	printf("up to %d\n", shu);
	printf("%d\n", tot);
	printf("%lf", up[shu-1]);*/
	maxnum=shu-1;

}

double n;

int main()
{
	int i, num;
	init();
	scanf("%d", &num);
	while (num-->0)
	{
		scanf("%lf", &n);
		for (i=1; i<=maxnum; ++i)
			if ( n < up[i]  || fabs(n-up[i])<1e-5 )
				break;
		n -= up[i-1];
		i = (int)(n-1);
		printf("%c\n", out[i]);
	}
	return 0;
}